#pragma once

#include <Common/Common.h>
#include <string>
#include <list>
#include "../Include/libAMQP.h"
using namespace std;

class CAMQPSubscribe : public IAMQPSubscribe,
                       public IRunnable
{
public:
    CAMQPSubscribe();
    virtual ~CAMQPSubscribe();

protected:
    // IAMQPSubscribe
    virtual void Release() override;
    virtual void SetServer(const char *lpszIP, unsigned short uPort) override;
    virtual void SetAuthentication(const char *lpszUserName, const char *lpszPassword) override;
    virtual void SetExchange(const char *lpszExchange) override;
    virtual void SetQueue(const char *lpszQueue) override;
    virtual void AddBind(const char *lpszBindKey) override;
    virtual void SetMessageCallback(AMQPSubscribeFunc fn) override;
    virtual void SetContext(void *pContext) override;
    virtual bool Initialize() override;

    // IRunnable
    virtual void OnRun() override;

protected:
    string                  m_strServerIP;
    UInt16                  m_uServerPort;

    string                  m_strUserName;
    string                  m_strPassword;

    string                  m_strExchange;
    string                  m_strQueue;
    list<string>            m_lstBindKey;

    AMQPSubscribeFunc       m_func;
    void*                   m_pContext;
    CThread                 m_thread;
};
